<template>
  <div class="switch" :style="{width:swit.wid}">
    <span v-for="(item,index) in swit.switchVal" :key="item.index" :class="{pos:ind==index}" @click="changeTrue(index)">{{ item }}</span>
  </div>
</template>

<script>
export default {
  name: 'SwitchCli',
  props: {
    swit: Object
  },
  data() {
    return {
      ind: 0
    };
  },
  methods: {
    changeTrue(ind) {
      this.ind = ind;
      this.$emit('changeTrue', ind);
    }
  }
};
</script>

<style scoped>
  .switch{
    height: 36px;
    font-size: 14px;
    background: #D8E4F6;
    border-radius: 18px;
    line-height: 36px;
    position: relative;
    margin: 12px 9px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    padding: 0px 1px;
  }
  .switch span{
    display: inline-block;
    /*width: 73px;*/
    color: #508FCC;
    text-align: center;
    flex-grow:1 ;
  }
  .switch .pos{
    height: 34px;
    margin-top: 1px;
    background: white;
    border-radius: 18px;
  }

</style>
